🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / desktopApp / src / test / kotlin / org / meshtastic / desktop / notification / DesktopMeshNotificationManagerTest.kt
Displaying Raw • Download
desktopApp/src/test/kotlin/org/meshtastic/desktop/notification/DesktopMeshNotificationManagerTest.kt bd2863243bab6eb213401d949839a2bc74dde7e2 (bd286324) Text, 2.49 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.desktop.notification
Tff7b72import T7ee787kotlinx.coroutines.ExperimentalCoroutinesApi
Tff7b72import T7ee787kotlinx.coroutines.test.UnconfinedTestDispatcher
Tff7b72import T7ee787kotlinx.coroutines.test.runTest
Tff7b72import T7ee787org.meshtastic.core.repository.Notification
Tff7b72import T7ee787org.meshtastic.core.repository.NotificationManager
Tff7b72import T7ee787kotlin.test.Test
Tff7b72import T7ee787kotlin.test.assertEquals
Tf0883e@OptInTb4b4b4(Te6edf3ExperimentalCoroutinesApiTff7b72::Te6edf3classTb4b4b4)
Tff7b72class T56d364DesktopMeshNotificationManagerTest Tb4b4b4{
T8b949e/** Records everything dispatched so the async bridge can be asserted deterministically. */
Tff7b72private Tff7b72class T56d364FakeNotificationManager Tb4b4b4: Te6edf3NotificationManager Tb4b4b4{
Tff7b72val Te6edf3dispatched Tff7b72= Te6edf3mutableListOfTff7b72<Te6edf3NotificationTff7b72>Tb4b4b4(Tb4b4b4)
Tff7b72override Tff7b72suspend Tff7b72fun Td2a8ffdispatchTb4b4b4(Te6edf3notificationTb4b4b4: Te6edf3NotificationTb4b4b4)Tb4b4b4: Tffa657Boolean Tb4b4b4{
Te6edf3dispatchedTb4b4b4.Te6edf3addTb4b4b4(Te6edf3notificationTb4b4b4)
Tff7b72return Tff7b72true
Tb4b4b4}
Tff7b72override Tff7b72fun Td2a8ffcancelTb4b4b4(Te6edf3idTb4b4b4: Tffa657IntTb4b4b4) Tb4b4b4{Tb4b4b4}
Tff7b72override Tff7b72fun Td2a8ffcancelAllTb4b4b4(Tb4b4b4) Tb4b4b4{Tb4b4b4}
Tb4b4b4}
Tf0883e@Test
Tff7b72fun Td2a8ff`showAlertNotification dispatches on the injected scope`Tb4b4b4(Tb4b4b4) Tff7b72= Te6edf3runTestTb4b4b4(Te6edf3UnconfinedTestDispatcherTb4b4b4(Tb4b4b4)Tb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3notificationManager Tff7b72= Te6edf3FakeNotificationManagerTb4b4b4(Tb4b4b4)
T8b949e// backgroundScope inherits the UnconfinedTestDispatcher, so the launched dispatch runs eagerly and is
T8b949e// observable synchronously — no virtual-time advance or manual teardown needed.
Tff7b72val Te6edf3manager Tff7b72= Te6edf3DesktopMeshNotificationManagerTb4b4b4(Te6edf3notificationManagerTb4b4b4, Te6edf3scope Tff7b72= Te6edf3backgroundScopeTb4b4b4)
Te6edf3managerTb4b4b4.Te6edf3showAlertNotificationTb4b4b4(Te6edf3contactKey Tff7b72= Ta5d6ff"Ta5d6ffcontact-1Ta5d6ff"Tb4b4b4, Te6edf3name Tff7b72= Ta5d6ff"Ta5d6ffAlertTa5d6ff"Tb4b4b4, Te6edf3alert Tff7b72= Ta5d6ff"Ta5d6ffSomething happenedTa5d6ff"Tb4b4b4)
Tff7b72val Te6edf3dispatched Tff7b72= Te6edf3notificationManagerTb4b4b4.Te6edf3dispatchedTb4b4b4.Te6edf3singleTb4b4b4(Tb4b4b4)
Te6edf3assertEqualsTb4b4b4(Ta5d6ff"Ta5d6ffAlertTa5d6ff"Tb4b4b4, Te6edf3dispatchedTb4b4b4.Te6edf3titleTb4b4b4)
Te6edf3assertEqualsTb4b4b4(Ta5d6ff"Ta5d6ffSomething happenedTa5d6ff"Tb4b4b4, Te6edf3dispatchedTb4b4b4.Te6edf3messageTb4b4b4)
Te6edf3assertEqualsTb4b4b4(Te6edf3NotificationTb4b4b4.Te6edf3CategoryTb4b4b4.Te6edf3AlertTb4b4b4, Te6edf3dispatchedTb4b4b4.Te6edf3categoryTb4b4b4)
Te6edf3assertEqualsTb4b4b4(Ta5d6ff"Ta5d6ffcontact-1Ta5d6ff"Tb4b4b4, Te6edf3dispatchedTb4b4b4.Te6edf3contactKeyTb4b4b4)
Tb4b4b4}
Tb4b4b4}
Served by rngit 1.5.0 - Generated in 0.09s